﻿using Microsoft.AspNetCore.Mvc;
using Zo.Config;
using Zo.Http;
using ZoLone.Custom;
using ZoLone.Logics.Sys;

namespace ZoLone.Areas.Admin.Controllers
{
    [AdminActionFilter(NoLogin = true)]
    public class LoginController : BaseController
    {
        AccountLogic _Logic = new AccountLogic();
        // GET: Admin/Login

        [Route(""), Route("/Admin/Login/")]
        public IActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public IActionResult Check(string UserName, string Password, string LoginCode)
        {
            var token = _Logic.Checked(UserName, Password, LoginCode);
            return Success(new
            {
                jumpurl = AppConfig.options.HomePageUrl,
                token
            });
        }

        /// <summary>
        /// 退出登录
        /// </summary>
        /// <returns></returns>
        public IActionResult Out()
        {
            HttpCookieHelper.RemoveCookie("Authorization");
            return RedirectToAction("Index");
        }
    }
}